<?php
/**
 * 记录签收照片
 * User: Administrator
 * Date: 2018\8\8 0008
 * Time: 11:30
 */

namespace app\lib\Order\OrderSign;


use app\model\OrderSignImgModel;

class AddOrderSignImg
{
    protected $signId;
    protected $opUid;
    protected $img;
    public function __construct($signId,$opUid,$img)
    {
        $this->signId = $signId;
        $this->opUid  = $opUid;
        $this->img    = $img;
    }

    /**
     * 执行代码
     * @return bool
     * @throws \Exception
     */
    public function save(){
        if(!(new GetOrderSignRecord($this->signId))->IsExit()) {
            exception('该签收记录不存在');
        }
        $model =  (new OrderSignImgModel());
        $data[$model->_createTime] = time();
        $data[$model->_createId]   = $this->opUid;
        $data[$model->_imgId]      = $this->img;
        $data[$model->_signId]     = $this->signId;
        $result =  $model->insert($data);
        if(!$result){
            exception('上传代签收图片失败');
        }
        return true;
    }

}